package com.kili.recommend.data.controller;

import com.kili.recommend.data.dto.CalculateScoreDto;
import com.kili.recommend.data.entity.Recommend;
import com.kili.recommend.data.mapper.RecommendMapper;
import com.kili.recommend.data.service.EventsService;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author fenny
 * @since 2019/08/28
 */
@RestController
public class KafkaController {

    @Resource
    private KafkaTemplate kafkaTemplate;

    @PostMapping(value = "send")
    public void sendMessage(String topic, String message) {
        kafkaTemplate.send(topic, message);
    }

    @Resource
    private RecommendMapper recommendMapper;

    @GetMapping("test")
    public List<Recommend> test(CalculateScoreDto dto) {
        return recommendMapper.calculateScore(dto);
    }

}
